home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.arch.arithmetic,comp.lang.c,comp.lang.c++
- Subject: Re: Access carry flag from C
- Date: Sat, 24 Feb 96 17:37:59 GMT
- Organization: none
- Message-ID: <825183479snz@genesis.demon.co.uk>
- References: <Dn1C9z.DGv.0.net@indra.com> <1996Feb1922.17.19.879@koobera.math.uic.edu> <31298D20.41C6@bazis.nl> <danpop.824859220@rscernix> <312AFACE.41C6@bazis.nl> <824997378snz@genesis.demon.co.uk> <312D850C.2781@bazis.nl>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <312D850C.2781@bazis.nl> fkorntne@bazis.nl "Franz Korntner" writes:
-
- >Lawrence Kirby wrote:
- >
- >> No. The value defined for INT_MAX in limits.h is the maximum value an int
- >> can hold *on that particular implementation*. The standard requires that
- >> INT_MAX be at least 32767 on all implementations (but it can be and
- >> often is higher). So on any implementation:
- >>
- >> int x = INT_MAX+1;
- >>
- >> is a guaranteed overflow.
- >
- >Wrong. The limits are minima. The above operation does not have to overflow!
-
- 5.2.4.2.1
-
- "- maximum value for an object of type int
- INT_MAX +32767"
-
- INT_MAX is a maximum (as its name suggests). +32767 is a minimum and is the
- smallest value an implementation is allowed to define INT_MAX to be. Hence
- int's on any implementation are resuires to be able to represent integers
- up to at least 32767. See Tanmoy's post for a more detailed (and correct)
- explanation.
-
- >> >and what I really miss in the
- >> >standard and/or implementation is a inline function 'maxlimitof(int)',
- >> >analogical to 'sizeof(int)'.
- >>
- >> That is precisely what INT_MAX gives you.
- >
- >INT_MAX is a constant. On some platforms you can force GCC to assume int's
- >to be 16 bit values. What about INT_MAX then?!?
-
- To remain conforming gcc would have to ensure that INT_MAX is defined to
- a value consistent with how an integer is represented for that particular
- compilation. It can do that easily by using conditional preprocessing within
- limits.h. Whether it does that in practice is another matter - as soon as
- you start playing around with type representations you will hit trouble
- if every translation unit doesn't use the same one, notably the standard
- library. Most likely you simply don't get a conforming compiler if you
- try to do this, notably where gcc is used with the standard library supplied
- by the system.
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-